var login = Vue.asyncComponent('Login/login');
var register = Vue.asyncComponent('Register/register');
var registerPre = Vue.asyncComponent('Register/registerPre');
var registerConfirm = Vue.asyncComponent('Register/registerConfirm');
var registerResult = Vue.asyncComponent('Register/registerResult');

var password = Vue.asyncComponent('Password/password');
var passwordPre = Vue.asyncComponent('Password/passwordPre');
var passwordConfirm = Vue.asyncComponent('Password/passwordConfirm');

var main = Vue.asyncComponent('Main/main');
var learn = Vue.asyncComponent('Learn/learn');

var router = new VueRouter({
	routes: [{
		path: '/',
		redirect: '/login'
	}, {
		path: '/login',
		component: login
	}, {
		path: '/main',
		component: main,
		children: [{
			path: 'learn',
			component: learn
		}]
	}, {
		path: '/password',
		component: password,
		children: [{
			// 这里不能使用/,要不然匹配的是/passwordPre，而还是password/passwordPre
			path: 'passwordPre',
			component: passwordPre
		}, {
			path: 'passwordConfirm',
			component: passwordConfirm
		}]
	}, {
		path: "/register",
		// redirect: '/register/registerPre', // 加上这句代码会出现路由重复出现的问题
		component: register,
		children: [{
			path: 'registerPre',
			component: registerPre
		}, {
			path: 'registerConfirm',
			component: registerConfirm
		}, {
			path: "registerResult",
			component: registerResult
		}]
	}]
});

/*router.beforeEach(function(to, from, next) {
	console.log("router beforeEach.");
	next(function(vm) {
		console.log(vm)
	});
});*/